<?php 

/**
 * 登录控制器
 */
class LoginController extends Controller{
    /**
     * 
     */
    public function index(){
    		$model = K('Admin');
			
    		if (IS_POST){
    			$username = Q('post.username');
    			$userInfo = $model->where("username='{$username}'")->find();
			if(!$userInfo){
				$this->error('用户不存在');
			}
			$password = Q('post.password', '', 'md5');
			if ($userInfo['password'] != $password){
				$this->error('用户名和密码不匹配');
			}
			$model->updateData($userInfo['aid']);
			setcookie(session_name(),session_id(),time() + 7*3600,'/');
			session('aid', $userInfo['aid']);
			session('aname', $userInfo['username']);
			$this->success('登录成功', U('Index/Index'));
    		}
			
    		$this->display(); 
    }
 }
 
 
 
 
 
 
 
 
 
 
 

 ?>